/****************************************************************************
	This file is part of Basqet.

	Basqet is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	Basqet is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
    along with Basqet.  If not, see <http://www.gnu.org/licenses/>.

****************************************************************************/

#include "notedatafactory.h"

#include "notedata.h"
#include "textnotedata.h"
#include "basketdescriptor.h"
#include "basketcontent.h"

#include <QDomElement>
#include <QtDebug>

NoteData* NoteDataFactory::createNoteByXML(BasketDescriptor* pBasket, BasketContent* pContent, QDomElement tag)
{
	NoteData* pNote = 0;

	QString	noteType = tag.nodeName();
	// qDebug() << "Factoring a note from ta node named" << noteType;

	if (noteType == "TextNote")
	{
		pNote = new TextNoteData(pBasket, pContent);
	}



	if (pNote)
	{
		pNote->setup(tag);
	}


	return pNote;

}

TextNoteData* NoteDataFactory::createNewTextNote(BasketDescriptor* pBasket, BasketContent* pContent)
{
	TextNoteData* pNote = new TextNoteData(pBasket, pContent);
	if (pBasket)
	{
		pNote->setup(pBasket->createTextNote());
	}

	return pNote;

}


TextNoteData* NoteDataFactory::createClonedTextNote(BasketDescriptor* pBasket, const TextNoteData* pOther)
{
    TextNoteData* pNote = 0;
	if (pOther)
	{
		pNote = new TextNoteData(pBasket, 0);
		if (pBasket)
		{
			pNote->setup(pBasket->createTextNote());
		}

		pNote->copyFrom(pOther);
	}

	return pNote;

}




